﻿
@{
    Layout = "_Layout";
}

<div class="row">
    <div class="col-lg-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>菜单设置</h5>
                <div class="ibox-tools">
                </div>
            </div>
            <div class="ibox-content">

                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>页面名称</th>
                            <th>路径</th>
                            <th>内页</th>
                        </tr>
                    </thead>
                    <tbody style="border:0" v-for="item in power">
                        <tr>
                            <td colspan="5"><b class="text-warning">{{item.groupName}}</b></td>
                        </tr>
                        <tr v-for="view in item.jurisdictViews">
                            <td>
                                <div class="checkbox checkbox-info checkbox-inline m-l-sm">
                                    <input type="checkbox" :id="view.actionApis[0].path" :value="view.actionApis[0].path" v-model="select">
                                    <label :for="view.actionApis[0].path"> {{view.actionApis[0].name}}</label>
                                </div>
                            </td>
                            <td>{{view.actionApis[0].path}}</td>
                            <td>
                                <div class="checkbox checkbox-info checkbox-inline m-l-sm" v-for="(action,index) in view.actionApis" v-if="index>0">
                                    <input type="checkbox" :id="action.path" :value="action.path" v-model="select">
                                    <label :for="action.path"> {{action.name}}</label>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="row">
                    <div class="col-lg-12">
                        <div><button class="btn btn-sm btn-primary pull-left m-t-n-xs ladda-button" data-style="zoom-in" type="submit" id="addmoney" v-on:click="add"><strong>保存</strong></button></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var vue = new Vue({
        el: "#bind",
        data: {
            power: [],
            select: [],
        },
        created: function () {
            var _this = this;
            get("/api/publicApi/GetPages", {}, function (res) {
                _this.power = res;
            })
            get("/menu/GetMenu", {}, function (res) {
                _this.select = res;
            })
        },
        methods: {
            add: function () {
                var _this = this;
                post("/menu/SaveMenu", { paths: _this.select }, function (res) {
                    if (res) {
                        alert("添加成功","success");
                    } else {
                        alert("添加失败", "error");
                    }
                })
            }
        },
        watch: {
            select: function () {
                console.log(this.select)
            }
        }
    })
</script>